Redis 使

threadingmultiprocessingCPUPythonRQ便
RQ使 Redis

RedisRedis RQredis-pyRedis
q.enqueue(...) enqueue()

RQ便 rqworker rqworker queue_name RQRedis RQ
from loguru import logger
from stock_downloader import stock_download
from multiprocessing.pool import Pool
from redis import Redis
from rq import Queue
stock_symbols = ['AAPL', 'NVDA', 'MSFT', 'JNJ']
logger.remove()
logger.add('/tmp/stock_downloader.log')
def main():
q = Queue(connection=Redis(host='localhost', port=6379))
for symbol in stock_symbols:
q.enqueue(stock_download, symbol)
if __name__ == '__main__':
main()


PythonRQ RQ使Celery使